// stores/counter.js
import { defineStore } from "pinia";

import { roleAddRequest, roleListRequest } from "@/libs/service/api/role/role";
import { ref } from "vue";
import { ElNotification } from "element-plus";

/**
 * 根
 */
export const rolePinia = defineStore("role", () => {
  // state
  const list: any = ref([]);
  const totla: any = ref(0);
  // actions
  async function roleListActions(playLoad: any) {
    const result: any = await roleListRequest(playLoad);
    list.value = result.data;
  }

  async function roleAddActions(params: any) {
    const result = await roleAddRequest(params);
    console.log(result);
    if (result.code == 200) {
      ElNotification({
        title: "成功",
        message: "提交成功",
        type: "success",
      });
    }
  }
  return {
    list,
    roleListActions,
    roleAddActions,
    totla,
  };
});
